package erfgame.frontend.desktop.view.operation;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import erfgame.frontend.desktop.view.AbstractView;

public class OperationView extends AbstractView {
	
	private JProgressBar progressBar;
	private JLabel label;
	private JPanel panel;
	
	public OperationView() {
		
	}
	
	public void init() {
		this.progressBar = new JProgressBar();
		this.label = new JLabel();
		this.panel = new JPanel( new GridBagLayout() );
		GridBagConstraints c = new GridBagConstraints();
		c.insets = new Insets(5, 5, 5, 5);
		c.gridwidth = GridBagConstraints.REMAINDER;
		c.fill = GridBagConstraints.HORIZONTAL;
		c.weightx = 1.0;
		panel.add( label, c );
		panel.add( progressBar, c );
	}
	
	public Component getComponent() {
		return this.panel;
	}
	
	public void setProgress( int step, int maxStep ) {
		this.progressBar.setMaximum( maxStep );
		this.progressBar.setValue( step );
	}
	
	public void setMessage( String message ) {
		this.label.setText( message );
	}
}
